const formatDateTime = (date) => {
  if (!date) return null
  return new Date(date).toISOString().slice(0, 19).replace('T', ' ')
}

const isDateInRange = (current, start, end) => {
  const now = new Date(current)
  const startTime = new Date(start)
  const endTime = new Date(end)
  return now >= startTime && now <= endTime
}

const getTimeDifference = (start, end) => {
  return Math.floor((new Date(end) - new Date(start)) / 1000 / 60) // 返回分钟
}

module.exports = {
  formatDateTime,
  isDateInRange,
  getTimeDifference,
}
